package com.example.activiti.leave.instener;


import com.example.activiti.leave.domain.WorkflowData;
import com.example.activiti.common.utils.spring.SpringUtils;
import com.example.activiti.leave.service.IWorkflowLeaveService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.Expression;


/**
 * @author Administrator
 */
public class LeaveEndStateListener implements ExecutionListener {
    private Expression state;

    @Override
    public void notify(DelegateExecution delegateExecution) {
        WorkflowData workflowData = new WorkflowData();
        workflowData.setId(delegateExecution.getProcessInstanceBusinessKey());
        workflowData.setState(state.getValue(delegateExecution).toString());
        SpringUtils.getBean(IWorkflowLeaveService.class).updateWorkflowLeave(workflowData);
    }
}
